import React,{Component} from 'react';
import Item from './Item';

import axios from 'axios';


export default class extends Component{

    constructor(props){
        super(props)
        this.state = {
            lists:[]
        }
    }

    componentDidMount(){
        axios.get('http://localhost:3008/article')
        .then( res =>{
            console.log(res)
            var lists = res.data;
            lists = lists.map( l =>{
                console.log(l)
                return <Item key={l._id} data={l}/>
            })

            this.setState({
                lists:lists
            })
        })
    }

    render(){
        return(
            
            <div  style={{marginTop:"60px"}}>

                {this.state.lists}
            </div>      
            
        )
    }
}